package io.demo3_路径;

import java.io.FileOutputStream;
import java.net.URLDecoder;

public class Test2 {
    public static void main(String[] args)throws Exception {
        //1.在当前工程根目录下的文件中写入数据
        FileOutputStream fos = new FileOutputStream("1.txt");
        //2.在当前工程的src目录下的文件中写入数据
        String path = Test2.class.getResource("/").getPath();
        System.out.println(path);
        System.out.println(URLDecoder.decode(path, "utf8"));
        //fos = new FileOutputStream(path+"/1.txt");
        //3.在当前类所在目录中的文件中写入数据
        path = Test2.class.getResource("").getPath();
        fos = new FileOutputStream(URLDecoder.decode(path, "utf8")+"/2.txt");

    }
}
